{extend name="public/layout" /}
{block name="head_css"}
    <style>
        .sam-header {
            background-color: #ff7200;
        }

        .sam-header .back,.sam-header .name,.sam-header .edit {
            display: inline-block;
            vertical-align: middle;
        }

        .sam-header .back {
            width: 20%;
            font-size: 0;
        }

        .sam-header .back>a .arrow,.sam-header .back>a .words {
            display: inline-block;
            vertical-align: middle;
        }

        .sam-header .back>a .arrow {
            width: 30%;
            padding-top: 30%;
            background-repeat: no-repeat;
            background-size: contain;
            background-position: center;
            background-image: url('/static/index/image/icon_arrow_back_fff.png');
        }

        .sam-header .back>a .words {
            font-size: 1rem;
        }

        .sam-header .name {
            width: 60%;
            font-size: 1rem;
            color: #fff;
            text-align: center;
        }

        .sam-header .edit {
            width: 20%;
            text-align: right;
            font-size: 1rem;
        }

        .sam-header .back>a,.sam-header .back>a:active {
            color: #fff;
            text-decoration: none;
        }

        .sam-header .edit>a,.sam-header .edit>a:active {
            color: #333;
            text-decoration: none;
        }
        .sam-header .icon {
            display: inline-block;
            width: 5%;
            padding-top: 5%;
            background-repeat: no-repeat;
            background-size: contain;
            background-position: center;
            background-image: url('/static/index/image/icon_header_list_fff.png');
            margin-right: 1%;
        }
        .submit-btn {
            width: 90%;
            box-sizing: border-box;
            padding: 2px 0;
            background-color: #ff7200;
            font-size: 0;
            color: #fff;
            text-align: center;
            margin: 15px auto 0 auto;
            border-radius: 1rem;
        }

        .submit-btn .icon,.submit-btn .words {
            display: inline-block;
            vertical-align: middle;
        }

        .submit-btn .icon {
            width: 10%;
            padding-top: 10%;
            background-repeat: no-repeat;
            background-size: contain;
            background-position: center;
            background-image: url('/static/index/image/icon_btn_publish_fff.png');
            transform: scaleX(-1);
            -webkit-transform: scaleX(-1);
        }

        .submit-btn .words {
            max-width: 50%;
            font-size: .9rem;
        }
        #sam-logo-uploader {
            width: 32%;
            background-size: 100%;
            padding-top: 7%;
            margin-top: 2%;
            background-repeat: no-repeat;
            background-position: center;
            background-image: url('/static/index/image/upload_logo.png');
            display:inline-block;
        }
        #sam-logo-uploader>input {
            display: none;
        }
        .sam-form-line .left{
            width: 21%;
        }
        .sam-form-line .right{
            width: 77%;
        }
        #logo{
            display: none;
            width: 20%;
        }
        .sam-image-shower{
            width: 31%;
        }
        #editor {
            width: 100%;
            height: 300px;
            overflow:scroll; max-height:300px
        }
    </style>
{/block}

{block name="main"}

    <div class="container sam-header">
        <div   class="back">
            <a href="{:url('index')}">
                <div class="arrow"></div>
            </a>
        </div>
        <div class="name">{$title}</div>
    </div>
    <div class="container sam-white-bg sam-form-line">
        <div class="left">
            <span>*</span>标题</div>
        <div class="right">
            <input type="text" id="title" name="title" value="{$vo.title}" placeholder="请输入标题"/>
        </div>
    </div>
    <div class="container sam-white-bg sam-form-line">
        <div class="left">
            <span>&nbsp;&nbsp;</span>详情</div>
    </div>
    </div>
    <div style="min-height: 200px;background-color: white" id="contentEditor"></div>
    <div id="submit" class="submit-btn">
        <div class="icon"></div>
        <div class="words">立即免费发布</div>
    </div>
{/block}
{block name="footer"}
{/block}
{block name="script"}
    <script src="/static/index/lib/eleditor/eleditor.min.js?v={$version}"></script>
    <script src="/static/index/lib/eleditor/webuploader.min.js?v={$version}"></script>
    <script>
        var Edr = new Eleditor({
            el: '#contentEditor',
            upload:{
                server: '{:url('Util/upload')}',
                fileSizeLimit: 5,//限制文件上传大小为2M
                formName: 'image',//设置文件name,
            },
        });
        {if condition="$vo.detail"}
        Edr.append("{$vo.detail}");
        {/if}
        $('#submit').on('click',function(){
            var _content = Edr.getContent();
            var url = "{$action}";
            var obj = new Object();
            obj.detail = _content;
            obj.title = $('#title').val();
            {if condition="$vo.id"}
            obj.id = {$vo.id};
            {/if}
            $.post(url,obj,function(data){
                if(data.code != 1){
                    alert(data.msg);
                }else{
                    alert('发布成功');
                    self.location='{$back_url}'
                }
            });
        });
    </script>
{/block}
